FILEFIND.FIRST Function

Syntax

obj as P = FILEFIND.First(C pattern[,N file_attribute])

Arguments

patternCharacter

A pattern to select file names using wildcard characters like ?*' and ?? '.

file_attributeNumeric

Default = 0 (normal files). The File_Attribute parameter is a numeric value specifying the type of file to find. You can find files that have one or more of the following attributes:

File Attribute
Description
FILE_FIND_NORMAL

Normal

FILE_FIND_READONLY

Read-only

FILE_FIND_HIDDEN

Hidden

FILE_FIND_SYSTEM

System

FILE_FIND_LABEL

Label

FILE_FIND_DIRECTORY

Directory

FILE_FIND_ARCHIVE

Archive

FILE_FIND_AND_FLAGS

Specifies that multiple flags should be ANDed together rather than ORed. By default flags are ORed.

FILE_FIND_NOT_READONLY

Files that are NOT read-only

FILE_FIND_NOT_DIRECTORY

Files that are NOT directory files

FILE_FIND_NOT_ARCHIVE

Files that do not have their archive bit turned on.

FILE_FIND_AND_NOT_FLAGS

Specifies that when multiple "NOT" flags are used that the flags should be ANDed together.

Returns

objPointer

Returns an object pointer that can be used to find all files in a directory.

Description

Find first file, returns a new FileFind object pointer to the file(s).

Discussion

The FILEFIND.FIRST() method creates the object pointer that can be used to find all of the files in a directory. will refer to all files matching the specified File_Pattern (wildcard characters like ?*' and ?? ' are used). The optional File_Attribute parameter is a numeric value specifying the type of file to find. See FILEFIND.GET() for information about this parameter. Note : FILEFIND.FIRST()is obsolete, and is included for backward compatibility. The FILEFIND.GET() method is the preferred method for getting a list of files.

Example

Populate an array with the names of all tables in the A_SPORTS directory. Then let the user choose a table from the list.

dim file_names250 as C
old_directory = dir_get()
DIR_put("c:\a5\a_sports")
files = FILEFIND.first("*.dbf")
i = 1
while .not. files.eof()
    file_namesI = files.name()
    files.next()
    i = i + 1
end while
dir_put(old_directory)
file_names.sort()
filename = ui_get_list_array("Choose a Table", 1, "file_names")
if filename = "" then
    end
end if

List all sub-directories in the specified path.

dirs = FILEFIND.first("c:\a5\*.*",16)
while .not. dirs.eof()
    dir_name = dirs.name()
    dirs.next()
    trace.writeln(dir_name)
end while

List all sub-directories (including read only directories) in the specified path.

dirs = FILEFIND.first("c:\a5\*.*", FILE_FIND_DIRECTORY + FILE_FIND_READONLY)
while .not. dirs.eof()
    dir_name = dirs.name()
    dirs.next()
    trace.writeln(dir_name)
end while

See Also